package com.lipaluma.test.db.internal.assertions;

import static org.junit.Assert.assertEquals;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * test a string column
 * @author Mario
 */
class StringColumn extends Column<String> {
	
	private StringColumn(Builder builder) {
		super(builder);
	}
	
	public static StringColumn.Builder builder(String request) {
		return new Builder(request);
	}

	@Override
	public void assertValue(ResultSet rs) throws SQLException {
		if(name == null)
			assertEquals(getErrorMessageOnIndexColumn(), expectedValue, rs.getString(index));
		else
			assertEquals(getErrorMessageOnNamedColumn(), expectedValue, rs.getString(name));
	}

	public static class Builder extends Column.Builder<String>  {

		public Builder(String request) {
			super(request);
		}

		@Override
		public StringColumn.Builder withExpectedValue(String expected) {
			this.expectedValue = expected;
			return this;
		}

		@Override
		public StringColumn build() {
			return new StringColumn(this);
		}

	}


}
